const { Node, LinkedList } = require('./linkedList');
let linkedList = new LinkedList()
linkedList.append(4)
linkedList.append(5)
linkedList.append(1)
linkedList.append(9)
var deleteNode = function (node) {
  let head = linkedList.head
  const dummy = new Node(0);
  dummy.next = head;

  let pre = dummy;
  if (head === null) {
    return null
  }
  let cur = head
  while (cur !== null && cur.data !== node) {
    pre = cur;
    cur = cur.next;
  }
  if (cur !== null) {
    pre.next = cur.next
  }
  return dummy.next
};
let res = deleteNode(1)
console.log(JSON.stringify(res));
